//
//  WYCUserModel.m
//  信用卡管理
//
//  Created by 中企互联 on 2017/11/23.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "WYCUserModel.h"

@implementation WYCUserModel

static WYCUserModel *singletonModel = nil;
+ (WYCUserModel *)defaultModel {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        singletonModel = [[WYCUserModel alloc] init];
    });
    return singletonModel;
}

- (void)setToken:(NSString *)token{
    
    [[NSUserDefaults standardUserDefaults] setObject:token forKey:@"token"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)token{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"token"];
    
}


- (void)setbankName:(NSString *)bankName{
    
    [[NSUserDefaults standardUserDefaults] setObject:bankName forKey:@"bankName"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)bankName{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"bankName"];
    
}


- (void)setcardNumber:(NSString *)cardNumber{
    
    [[NSUserDefaults standardUserDefaults] setObject:cardNumber forKey:@"cardNumber"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)cardNumber{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"cardNumber"];
    
}


- (void)setcreateTime:(NSString *)createTime{
    
    [[NSUserDefaults standardUserDefaults] setObject:createTime forKey:@"createTime"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)createTime{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"cardNumber"];
    
}


- (void)setidnumber:(NSString *)idnumber{
    
    [[NSUserDefaults standardUserDefaults] setObject:idnumber forKey:@"idnumber"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)idnumber{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"idnumber"];
    
}


- (void)setlastLoginTime:(NSString *)lastLoginTime{
    
    [[NSUserDefaults standardUserDefaults] setObject:lastLoginTime forKey:@"lastLoginTime"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)lastLoginTime{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"lastLoginTime"];
    
}


- (void)setmobile:(NSString *)mobile{
    
    [[NSUserDefaults standardUserDefaults] setObject:mobile forKey:@"mobile"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)mobile{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"mobile"];
    
}


- (void)setuserName:(NSString *)userName{
    
    [[NSUserDefaults standardUserDefaults] setObject:userName forKey:@"userName"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)userName{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"userName"];
    
}


- (void)setticket:(NSString *)ticket{
    
    [[NSUserDefaults standardUserDefaults] setObject:ticket forKey:@"ticket"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)ticket{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"ticket"];
    
}

- (void)setuserId:(NSString *)userId{
    
    [[NSUserDefaults standardUserDefaults] setObject:userId forKey:@"userId"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)userId{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"userId"];
    
}


- (void)setrepaymentRate:(NSString *)repaymentRate{
    
    [[NSUserDefaults standardUserDefaults] setObject:repaymentRate forKey:@"repaymentRate"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

- (NSString *)repaymentRate{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"repaymentRate"];
    
}


- (void)clearUserModel {
    
    // 先将其转化为字典，然后用forin遍历删除即可
    NSUserDefaults *defatluts = [NSUserDefaults standardUserDefaults];
    NSDictionary *dictionary = [defatluts dictionaryRepresentation];
    for(NSString *key in [dictionary allKeys]){
        [defatluts removeObjectForKey:key];
        [defatluts synchronize];
    }
    
}
@end
